﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.BLL;
using Grove.ORM;
using HZ.MBSM.Model;
using HZ.MBSM.DBUtility;
public partial class Manage_ChangePwd : System.Web.UI.Page, IPageDescribe
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            
        }
        else
        {
            
        }
    }


    protected void queding_Click(object sender, EventArgs e)
    {
        Int64 AccountId;
        string strSql;
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        if (_Account != null)
        {
            if (NewPwd.Text.Trim() != ConfirmPwd.Text.Trim())
            {
                Response.Write("<script>window.alert('新密码与确认密码不一致');</script>");
            }
            else if (OldPwd.Text.Trim() == NewPwd.Text.Trim())
            {
                Response.Write("<script>window.alert('新密码不能和旧密码相同！');</script>");
            }
            else
            {

                if (OldPwd.Text.Trim() != SysFun.PasswordDecrypt(SysFun.ToTrim(_Account.Pwd_Bid)))
                {
                    Response.Write("<script>window.alert('原密码不正确');</script>");

                }
                else
                {
                    AccountId = SysFun.ToLong(_Account.AccountId);
                    Db db = new Db();
                    strSql = "update Account set Pwd_Bid='" + SysFun.PasswordEncrypt(SysFun.ToTrim(NewPwd.Text)) + "' where AccountId=" + AccountId.ToString();
                    db.Command(strSql);
                    db.Close();
                    HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "删除", "Account", strSql, "../Magage/ChangePwd.aspx");

                    Response.Write("<script>window.opener.location.reload();window.close();</script>");
                    Response.Write("<script>window.alert('修改密码成功');</script>");

                }

            }
        }
        else
        {
            Response.Write("<script>window.alert('你还没有登录,请登录后再修改!!!');</script>");
        }

    }
    #region IPageDescribe 成员

    public string Name
    {
        get { return "修改密码"; }
    }

    public string Describe
    {
        get { return ""; }
    }

    public string ParentName
    {
        get { return "修改密码"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumBidGoods );
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCheckCompany);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCheckGoods);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCheckProjectComp);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumSupervise);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHospitale);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHMedicine);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHMedicineCompany);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumZMedicine);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumZMedicineCompany);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumBiaosuff);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumRquestion);

            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumComapanyRG);
            return _AccountType;
        }
    }

    #endregion
}
